import { camelCase } from "../case"
import httpClient from "../httpclient"


export class StoreRatingQuery {

  private params = {}

  public storeId(storeId: string): StoreRatingQuery {
    this.params["store_id"] = storeId
    return this
  }

  public date(date: string | number): StoreRatingQuery {
    this.params["date"] = date
    return this
  }

  public dateFrom(dateFrom: string | number): StoreRatingQuery {
    this.params["date_from"] = dateFrom
    return this
  }

  public dateTo(dateTo: string | number): StoreRatingQuery {
    this.params["date_to"] = dateTo
    return this
  }
}

export class TotalStoreRatings {
  public productReviewRating: number
  public productPricingRating: number
  public courierServiceRating: number
  public customerServiceRating: number
  public productShippingRating: number
}


export class StoreRatingReportV1 {

  public static createStoreRatingQuery() {
    return new StoreRatingQuery()
  }

  public static queryTotalStoreRatings(query: StoreRatingQuery): Promise<TotalStoreRatings> {
    return httpClient.get("/v1/reports/total-store-ratings", {
      params: query["params"],
    })
      .then(({ data }) => data)
      .then(camelCase)
  }
}
